<template>
  <div class="sso-container">
    <!-- 联云logo -->
    <div>
      <img class="lylogo" src="@/assets/images/lylogo.png" alt="" />
    </div>
    <div class="login-info">
      <!-- 登录模块 -->
      <div class="login">
        <div class="login-layout">
          <h2 class="projectName">{{ projectName }}</h2>
          <el-button class="sso-btn" @click="ssoLogin" type="primary">系统登录</el-button>
        </div>
      </div>
      <!-- 平台技术服务 -->
      <!-- <div class="serve">
        <h2>平台技术服务</h2>
        <h2>联系电话：54537/0759-8572537</h2>
      </div> -->
    </div>
  </div>
</template>

<script lang="ts" setup>
import { reactive } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { useUserInfoStore } from '@/store/modules/userInfo'

const router = useRouter()
const route = useRoute()
const userInfoStore = useUserInfoStore()

const projectName = import.meta.env.VITE_APP_NAME
const loginData = reactive({
  account: 'admin',
  pwd: '123456',
  imgcode: ''
})

const ssoLogin = () => {
  // location.href = import.meta.env.VITE_CALLBACK;
  userInfoStore.setUser({ ...loginData, token: '这是测试把token放进store中的user变量中的' })
  let redirect = route.query.redirect || '/home'
  if (typeof redirect !== 'string') { // 此处的目的是防止有的路由不是string类型，提高代码容错率
    redirect = '/'
  }
  router.replace(redirect)
}
</script>
<style lang="scss" scoped>
h2 {
  margin: 0;
  padding: 0;
}
.sso-container {
  width: 100%;
  height: 100vh;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center center;
  background-image: url("@/assets/images/login-bg.png");
  display: flex;
  justify-content: space-between;
  .lylogo {
    width: 157px;
    height: 28px;
    margin-left: 40px;
    margin-top: 32px;
  }
  .login-info {
    background-color: rgba(255, 255, 255, 0.95); // 42 71 92
    width: 640px;
    height: 100vh;
    .login {
      height: calc(100vh - 157px);
      width: 640px;
      display: flex;
      align-items: center;
      justify-content: center;
      .login-layout {
        width: 640px;
        text-align: center;
        .projectName {
          height: 45px;
          font-size: 32px;
          font-family: PingFang SC, PingFang SC-Semibold;
          font-weight: 600;
          color: #0b3ba7;
        }
        .sso-btn {
          margin-top: 42px;
          width: 378px;
          height: 55px;
        }
      }
    }
    .serve {
      height: 157px;
      h2 {
        font-size: 14px;
        font-family: PingFang SC, PingFang SC-Regular;
        font-weight: 400;
        color: #000000;
      }
      :nth-child(2) {
        margin-top: 18px;
      }
      :nth-child(3) {
        margin-top: 14px;
      }
    }
  }
}
</style>
